package com.aier.classes.common;

import java.util.HashMap;
import java.util.Map;

public class InviteRequestUtil {

    
    /**
     * 邀请中,同意,拒绝
     */
    public static Map<Short,String> InviteStateMap;
    public static final short INVITE_TYPE_WAIT = 0;
    public static final short INVITE_TYPE_AGREE = 1;
    public static final short INVITE_TYPE_REFUSE = 2;

    /**
     * 申请中,审核通过,审核失败
     */
    public static Map<Short,String> RequestStateMap;
    public static final short REQUEST_TYPE_WAIT = 0;
    public static final short REQUEST_TYPE_AGREE = 1;
    public static final short REQUEST_TYPE_REFUSE = 2;
    
    /**
     * 发送消息过滤字处理
     */
    public static Map<String,String> filterMap;
    
    static{
        InviteStateMap = new HashMap<Short,String>();
        InviteStateMap.put(INVITE_TYPE_WAIT,"邀请中");
        InviteStateMap.put(INVITE_TYPE_AGREE,"同意");
        InviteStateMap.put(INVITE_TYPE_REFUSE,"拒绝");
        
        RequestStateMap = new HashMap<Short,String>();
        RequestStateMap.put(REQUEST_TYPE_WAIT,"申请中");
        RequestStateMap.put(REQUEST_TYPE_AGREE,"审核通过");
        RequestStateMap.put(REQUEST_TYPE_REFUSE,"审核失败");
        
        filterMap = new HashMap<String,String>();
        //filterMap.put("方便", "方 便");
        //filterMap.put("老师", "老 师");
        //filterMap.put("家长", "家 长");
        //filterMap.put("学校", "学 校");
        //filterMap.put("学生", "学 生");
        //filterMap.put("家校", "家 校");
        //filterMap.put("安全", "安 全");
        //filterMap.put("到校", "到 校");
        //filterMap.put("离校", "离 校");
        //filterMap.put("儿园", "儿 园");
        //filterMap.put("幼儿", "幼 儿");
        filterMap.put("孙中山", "孙 中 山");
        //filterMap.put("宋庆龄", "宋 庆 龄");
        //filterMap.put("班级", "班 级");
        //filterMap.put("黄色", "黄 色");
        filterMap.put("'", "’");
    }
    
    /**
     * 过滤某些关键字
     * @return
     */
    public static String getFilterMessage(String message){
        String new_message = message;
        for (Map.Entry<String,String> entry : filterMap.entrySet()) {  
//            System.out.println("key = " + entry.getKey() + " and value = " + entry.getValue());  
            new_message = new_message.replace(entry.getKey(), entry.getValue());
        }  
        return new_message;
    }
    
    /**
     * 拼接发送邀请时发送的短信内容：教师邀请
     * @return
     */
    public static String getIRTeacherMessage(String tname,String schoolName,String className){
        StringBuffer irMessage = new StringBuffer(tname+"老师邀请您加入--"); 
        irMessage.append(schoolName);
        if(className!=null){
            irMessage.append(" " + className);
        }
        irMessage.append(" 加入免费,回复'TY'接受邀请");
        return getFilterMessage(irMessage.toString());
    }
    
    /**
     * 拼接发送邀请时发送的短信内容：教师添加
     * @return
     */
    public static String getAddTeacherMessage(String tname,String schoolName,String className,String account,String pwd){
        StringBuffer irMessage = new StringBuffer(tname+"老师已将您成功加入--"); 
        irMessage.append(schoolName);
        if(className!=null){
            irMessage.append(" " + className);
        }
        if (!"".equals(pwd)) {
            irMessage.append(",您的账号为:"+account+",密码是:" + pwd);
        }
        irMessage.append(",欢迎登录www.aier360.com进行家校沟通" );
        
        return getFilterMessage(irMessage.toString());
    }
    
    /**
     * 拼接发送邀请时发送的短信内容：家长邀请
     * @return
     */
    public static String getIRParentMessage(String tname,String studentName,String className,String schoolName){
        StringBuffer irMessage = new StringBuffer(tname+"老师邀请您加入");
        irMessage.append(studentName + "所在的" + schoolName + className);
        irMessage.append(" 加入免费,回复'PY'接受邀请");
        return getFilterMessage(irMessage.toString());        
    }
    
    /**
     * 拼接发送邀请时发送的短信内容：家长添加
     * @return
     */
    public static String getAddParentMessage(String tname,String studentName,String className,String schoolName,
            String account,String pwd){
        StringBuffer irMessage = new StringBuffer(tname+"老师已将您成功加入");
        irMessage.append(studentName + "所在的" + schoolName + className);
        if (!"".equals(pwd)) {
            irMessage.append(",您的账号为:"+account+",密码是:" + pwd);
        }
        irMessage.append(",欢迎登录www.aier360.com进行家校沟通" );
        return getFilterMessage(irMessage.toString());        
    }
    
    /**
     * 拼接 发送邀请的回执短信内容：教师邀请 ---(有无账号内容不同)
     * @return
     */    
    public static String returnIRTeacherMessage(String account,String schoolName,String className,String pwd){
        StringBuffer irMessage = new StringBuffer("您已成功加入"+ schoolName);
        if(className!=null){
            irMessage.append(className);
        }
        if(!"".equals(pwd)){
            irMessage.append(",您的账号为:"+account+",密码是:" + pwd);
        }
        irMessage.append(",欢迎登录www.aier360.com进行家校沟通" );
        return getFilterMessage(irMessage.toString());    
    }    
    
    /**
     * 拼接 发送邀请的回执短信内容：家长邀请---(有无账号内容不同)
     * @return
     */    
    public static String returnIRParentMessage(String account,String studentName,String className,String schoolName,String pwd){
        StringBuffer irMessage = new StringBuffer("您已成功加入"+ studentName + "所在的" + schoolName + className);
        if(!"".equals(pwd)){
            irMessage.append(",您的账号为:"+account+",密码是:" + pwd);
        }    
        irMessage.append(",欢迎登录www.aier360.com进行家校沟通" );
        return getFilterMessage(irMessage.toString());    
    }
    
    
}